<div class="tab_item" style="display: block">
    <div class="toolbar clearfix">
        <div class="float_right">

        </div>
        <h3>电池</h3>
    </div>
    <div class="grid" style="height:345px;">
        <table id="page_table_box_${pid}"></table>
    </div>
</div>

<script>
    $(function () {
        $('#page_table_box_${pid}').datagrid({
            fit: true,
            width: '100%',
            height: '100%',
            striped: true,
            pagination: true,
            url: "${contextPath}/security/hdw/battery/page.htm?packId=${packId}",
            fitColumns: true,
            pageSize: 10,
            pageList: [10, 50, 100],
            idField: 'id',
            singleSelect: true,
            selectOnCheck: false,
            checkOnSelect: false,
            autoRowHeight: false,
            rowStyler: gridRowStyler,
            columns: [
                [
                    {
                        title: '电池序号',
                        align: 'center',
                        field: 'batteryId',
                        width: 60,
                        formatter: function (val, row) {
                            return row.id;
                        }
                    },
                    {
                        title: '对应订单',
                        align: 'center',
                        field: 'orderId',
                        width: 60
                    },                    {
                        title: '厂商',
                        align: 'center',
                        field: 'supplierName',
                        width: 60
                    },
                    {
                        title: '当前电量',
                        align: 'center',
                        field: 'volume',
                        width: 60
                    },
                    {
                        title: '状态',
                        align: 'center',
                        field: 'statusName',
                        width: 40
                    },
                    {
                        title: '充电阶段',
                        align: 'center',
                        field: 'chargeStage',
                        width: 60,
                        formatter: function (val, row) {
                            switch (val) {
                                case 4:
                                    return '已充满'
                                default:
                                    return '未充满';
                            }
                        }
                    },
                    {
                        title: '使用次数',
                        align: 'center',
                        field: 'exchangeAmount',
                        width: 60
                    },
                    {
                        title: '操作',
                        align: 'center',
                        field: 'id',
                        width: 60,
                        formatter: function (val, row) {
                        <@app.has_oper oper_code='3_2_2'>
                            var html = ' <a href="javascript:remove_${pid}(\'ID\')">删除</a>'
                            return html.replace(/ID/g, row.id);
                        </@app.has_oper>
                        }
                    }
                ]
            ],
            onLoadSuccess: function () {
                $('#page_table_box_${pid}').datagrid('clearChecked');
                $('#page_table_box_${pid}').datagrid('clearSelections');
            }
        });
    });

    function remove_${pid}(id) {
        $.messager.confirm('提示信息', '确认删除?', function (ok) {
            if (ok) {
                $.post("${contextPath}/security/hdw/battery/delete.htm?id=" + id, function (json) {
                    if (json.success == 1) {
                        $.messager.alert('提示消息', '操作成功', 'info');
                        $('#page_table_box_${pid}').datagrid('reload');
                    } else {
                        $.messager.alert('提示消息', json.message, 'info');
                    }
                }, 'json');
            }
        });
    }
</script>